class LoginController < ApplicationController
  skip_before_filter :authenticate, :only => [:login]
  layout "groupware" 

  def login
    
    if request.post?
    @usuario = Usuario.find_by_nome_and_senha(params[:login],params[:senha])
    if @usuario
      session[:usuario] = @usuario.id
      if session[:return_to] && !session[:return_to].include?(url_for(:action => "login"))
        redirect_to session[:return_to]
        session[:return_to] = nil
      else
        redirect_to :controller => "groupware"
       end
    else
      flash[:notice] = "Invalid Login and/ord password " 
      end
    end
  end

  def logout
    session[:usuario] = nil
    redirect_to :controller => "groupware"
  end
  
end
